package com.jia.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: Leetcode
 * @description: https://leetcode-cn.com/contest/biweekly-contest-17/problems/decompress-run-length-encoded-list/
 * @author: STU756
 * @create: 2020-08-21 20:29
 */
public class Pro1313 {
    public int[] decompressRLElist(int[] nums) {
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < nums.length; i+=2) {
            int freq = nums[i];
            int val = nums[i+1];
            while(freq-- > 0)
                list.add(val);
        }
        int[] res = new int[list.size()];
        for(int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    }
}
